package com.dou361.ijkplayer.widget;

import android.app.Activity;
import android.content.res.Resources;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.Animation;
import android.widget.GridView;

import com.dou361.ijkplayer.R;
import com.dou361.ijkplayer.adapter.RewardGridAdapter;
import com.dou361.ijkplayer.basepopup.BasePopupWindow;

/**
 * Created by Administrator on 2017/7/19.
 */

public class SlideBottomShare extends BasePopupWindow {
    private View popupView;
    private Activity mActivity;
    private GridView gridView;
    public SlideBottomShare(Activity context) {
        super(context);
        this.mActivity=context;
        bindEvent();
    }
    //初始化控件
    private void bindEvent() {
        if(popupView!=null){
            gridView = popupView.findViewById(R.id.share_grid);
            setAdapter();


        }
    }
    //适配数据
    private void setAdapter() {
        Resources resources = mActivity.getResources();
        String[] array = resources.getStringArray(R.array.comment);
        int []img=new int[]{R.drawable.qq,R.drawable.zone,R.drawable.wchat,R.drawable.friends,R.drawable.sina};
        RewardGridAdapter adapter= new RewardGridAdapter(mActivity)
        {
            @Override
            public int getImgId() {
                return R.id.comment_item_img;
            }

            @Override
            public int getTvId() {
                return R.id.comment_item_tv;
            }

            @Override
            public View getRes() {
                return View.inflate(mActivity,R.layout.comment_item,null);
            }
        };
        adapter.setData(array,img);
        gridView.setAdapter(adapter);

    }
    @Override
    public View onCreatePopupView() {
        popupView = LayoutInflater.from(getContext()).inflate(R.layout.simple_bottom_share, null);
        return popupView;
    }

    @Override
    public View initAnimaView() {
        return popupView.findViewById(R.id.share_rela);
    }

    @Override
    protected Animation initShowAnimation() {
        return getTranslateAnimation(250 * 2, 0, 300);
    }

    @Override
    public View getClickToDismissView() {
        return popupView.findViewById(R.id.share_cancle_img);
    }
}
